import React from 'react';
import { render } from 'react-dom';
import Message from './Message';

const div = document.createElement('div');

function initMessage(content, duration, type, onClose) {
	document.body.appendChild(div);
	return render(<Message wrapper={div} content={content} duration={duration} type={type} onClose={onClose} />, div);
}

function success(content, duration, onClose) {
	return initMessage(content, duration, 'success', onClose);
}

function error(content, duration, onClose) {
	return initMessage(content, duration, 'error', onClose);
}

function warning(content, duration, onClose) {
	return initMessage(content, duration, 'warning', onClose);
}

export default {
	success,
	error,
	warning
};